package top.yokey.learn2;

import android.app.Application;
import android.content.SharedPreferences;
import android.util.Log;

import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;

import top.yokey.learn2.view.PullRefreshViewHelper;

public class MyApp extends Application {
    private static MyApp instance = null;
    private SharedPreferences sharedPreferences;
    private SharedPreferences.Editor editor;

    public static MyApp get() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        Log.i("TAGS", "MyAPP");
        PullRefreshViewHelper.get().init(14);
        PullRefreshViewHelper.get().setColors(getColors(R.color.teal_700), getColors(R.color.teal_200));
        PullRefreshViewHelper.get().setLoadStyle(PullRefreshViewHelper.LOAD_STYLE_WAVE);
        PullRefreshViewHelper.get().setLoadColor(getColors(R.color.teal_700));
        PullRefreshViewHelper.get().setLoadText("加载中...");
        PullRefreshViewHelper.get().setEmptyImage(R.mipmap.ic_pull_refresh);
        PullRefreshViewHelper.get().setEmptyColor(getColors(R.color.teal_700));
        PullRefreshViewHelper.get().setEmptyText("暂无数据~");
        PullRefreshViewHelper.get().setErrorImage(R.mipmap.ic_pull_refresh);
        PullRefreshViewHelper.get().setErrorColor(getColors(R.color.teal_700));
        PullRefreshViewHelper.get().setErrorText("加载失败了~");
        sharedPreferences = getSharedPreferences("demo", MODE_PRIVATE);
        editor = sharedPreferences.edit();

        SDKInitializer.initialize(this);
        //自4.3.0起，百度地图SDK所有接口均支持百度坐标和国测局坐标，用此方法设置您使用的坐标类型.
        //包括BD09LL和GCJ02两种坐标，默认是BD09LL坐标。
        SDKInitializer.setCoordType(CoordType.BD09LL);
    }

    public int getColors(int id) {
        return getResources().getColor(id);
    }

    public SharedPreferences getSharedPreferences() {
        return sharedPreferences;
    }

    public SharedPreferences.Editor getEditor() {
        return editor;
    }

}
